// @author chenjw
//引入vue和Vuex
import Vue from 'vue'
import Vuex from 'vuex'

//引入之后，对vuex进行引用
Vue.use(Vuex);

const saveState = sessionStorage.getItem('store') ? JSON.parse(sessionStorage.getItem('store')) : {
	defaultActive: 2, //左边导航选中参数
	defaultOpeneds: [], //左边导航打开参数
	identityType: 'advert', //身份转换参数
	accToken: '', //接口token
}

export default new Vuex.Store({
	state: saveState,
	mutations: {
		setAefaultActive(state, val) {
			state.defaultActive = val || 2
		},
		setDefaultOpeneds(state, val) {
			state.defaultOpeneds = val || []
		},
		setIdentityType(state, val) {
			state.identityType = val || 'advert'
		},
		setAccToken(state, val) {
			console.log(val)
			state.accToken = val || ''
		},

	}
});
